#include <iostream>

using namespace std;
typedef long long LL;
LL n;
const int p = 1e9 + 7;
LL qpow(LL a, LL b, LL p)
{
	LL ret = 1;
	while (b)
	{
		if (b & 1) ret = ret * a % p;
		a = a * a % p;
	
		b >>= 1;
	}
	return ret;
}
int main()
{
	while (cin >> n)
	{
		LL a = n % p, b = (n + 1) % p, c = (n * 2 + 1) % p, d = qpow(6, p - 2, p);
		cout << (((a * b) % p * c) % p * d) %p << endl;
	}
	
	return 0;
}